home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / M / MacOberon241.cpt / MacOberon 2.4(1) / Automatic.Mod (.txt) < prev    next >
Oberon Text  |  1991-10-17  |  1KB  |  33 lines

  1. Syntax10.Scn.Fnt
  2. MODULE Automatic;    (* Michael Franz, 3.11.90 *)
  3.     (*    A simple macro facility for executing several commands at once.
  4.             Example:
  5.                 Automatic.Do
  6.                     System.Directory *.Mod
  7.                     System.ShowCommands System ~
  8.                     Browser.ShowDef TextFrames ~
  9.                 ~
  10.     IMPORT
  11.         Display, Texts, Viewers, Oberon;
  12.         W: Texts.Writer;
  13.     PROCEDURE NextLine(text: Texts.Text; pos: LONGINT): LONGINT;
  14.         VAR R: Texts.Reader; ch: CHAR;
  15.     BEGIN
  16.         IF    pos < text.len    THEN    Texts.OpenReader(R, text, pos); Texts.Read(R, ch);
  17.             WHILE    ~ R.eot & (ch # 0DX)    DO    Texts.Read(R, ch)    END;
  18.             IF    R.eot    THEN    RETURN -1    ELSE    RETURN Texts.Pos(R)    END
  19.         ELSE    RETURN -1    END
  20.     END NextLine;
  21.     PROCEDURE Do*;
  22.         VAR S: Texts.Scanner; text: Texts.Text; vwr: Viewers.Viewer; frame: Display.Frame; pos: LONGINT; par: Oberon.ParList; res: INTEGER;
  23.     BEGIN    Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S);
  24.         NEW(par); vwr := Oberon.Par.vwr; frame := Oberon.Par.frame; text := Oberon.Par.text;
  25.         WHILE    S.class = Texts.Name    DO    par.vwr := vwr; par.frame := frame; par.text := text; par.pos := Texts.Pos(S) - 1; pos := NextLine(text, par.pos);
  26.             Texts.WriteString(W, "Auto> "); Texts.WriteString(W, S.s); Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf);
  27.             Oberon.Call(S.s, par, FALSE, res);
  28.             IF    pos > 0    THEN    Texts.OpenScanner(S, text, pos); Texts.Scan(S)    ELSE    S.class :=Texts.Inval    END
  29.         END
  30.     END Do;
  31. BEGIN    Texts.OpenWriter(W);
  32. END Automatic.
  33.